home *** CD-ROM | disk | FTP | other *** search
/ 17 Bit Software 6: Level 6 / 17 Bit - Level 6 (1998)(Epic Marketing)[!].iso / quartz / q0867.dms / q0867.adf / TRAPDOOR.LZH / Rexx / TrimAreas.rexx < prev    next >
OS/2 REXX Batch file  |  1991-10-14  |  2KB  |  55 lines

  1. /* Trim all Fidonet message areas
  2.  
  3.    Usage: rx TrimAreas <dir>
  4.  
  5.    Your message area directories should be in a separate subdirectory.
  6.    The filenotes of the individual message directories should contain
  7.    the words "Days xx;", where xx is the number of days that messages
  8.    should be kept in that area.
  9.    All subdirectories in the specified <dir> will be trimmed.
  10. */
  11.  
  12. CSI     = '9b'x
  13. OFF     = CSI'0m'
  14. BO     = CSI'1m'
  15. UL     = CSI'4m'
  16. KEOL = CSI'K'
  17. CR   = '0d'x
  18. LF   = '0a'x
  19.  
  20. total = 0
  21. trimmed = 0
  22.  
  23. dir = strip(arg(1))
  24.  
  25. call writeln(stdout, 'Trimming message areas...')
  26. call writech(stdout, 'Scanning areas...')
  27. address command 'list >t:TrimAreas.Area' dir 'dirs lformat "%s%s"'
  28. address command 'sort t:TrimAreas.Area to t:TrimAreas'
  29. if open(areas,'t:TrimAreas','r') then do
  30.     do while ~eof(areas)
  31.         area = readln(areas)
  32.         call writech(stdout, CR||KEOL||'Area' area)
  33.         total = total+1
  34.         comment = subword(statef(area),8)
  35.         wp=find(comment,'Days')
  36.         if wp~=0 then do
  37.             trimmed = trimmed+1
  38.             days=strip(subword(comment,wp+1),'T',';')+0
  39.             call writech(stdout, ',' days 'days')
  40.             date=space(date('n',date('i')-days),1,'-')
  41.             date=left(overlay(substr(date,10,2),date,8,2),9)
  42.             call writech(stdout, ',' date)
  43.             address command 'list >t:TrimAreas.Area' area'/(0|1|2|3|4|5|6|7|8|9)#?.MSG upto' date 'lformat "delete %s%s quiet"'
  44.             address command 'execute t:TrimAreas.Area'
  45.         end
  46.     end
  47.     close(areas)
  48.     say CR||total 'areas,' trimmed 'trimmed.'||KEOL
  49.     address command "delete t:TrimAreas t:TrimAreas.Area quiet"
  50. end
  51. else
  52.     say LF'Cannot open temporary file t:TrimAreas'
  53.  
  54. return 0
  55.